package com.puyuba.puyuba.module;

import com.puyuba.puyuba.network.UserApi;
import com.pyb.java.network.RequestBodyUtil;
import com.pyb.java.network.RetrofitManger;
import com.pyb.java.network.observers.ResponseObserve;
import com.pyb.java.network.scheduler.RxSchedulers;

import java.util.HashMap;

import okhttp3.RequestBody;

public class UserModule {

    public static void loginOut(int userId, ResponseObserve<Object> observer) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("userId", userId);
        RequestBody bodyByMap = RequestBodyUtil.getRequestBodyByMap(map);
        RetrofitManger.getInstance().createService(UserApi.class)
                .logout(bodyByMap)
                .compose(RxSchedulers.applySchedulers())
                .subscribe(observer);
    }

    public static void getUserInfo(ResponseObserve<String> observer) {
        RetrofitManger.getInstance().createService(UserApi.class)
                .getUserInfo()
                .compose(RxSchedulers.applySchedulers())
                .subscribe(observer);
    }
}
